<template>
	<view class="category">
		<view class="tabs">
			<u-tabs @change="onClickTab" :current="current" keyName="title" :list="tabs" :inactiveStyle="{ color: '#ffffff', fontSize: '28rpx' }" :activeStyle="{ color: '#ffffff', fontSize: '28rpx', fontWeight: 'bold' }" lineColor="#b284dc"></u-tabs>
			<view class="desc">{{data.subtitle}}</view>
		</view>
		<view class="box">
			<u-grid :border="false" col="2">
				<u-grid-item :customStyle="{width: 50+'%'}" class="grid-item" v-for="(item, index) in data.markets" :key="index">
					<view class="col" @click.stop="navTo('/pages/market/collection',{id:item.id})">
						<view class="cover">
							<u--image radius="5" width="100%" height="350rpx" mode="aspectFill" :src="item.cover"></u--image>
						</view>
						<view class="name">{{item.name}}</view>
						<view class="artist">艺术家: {{item.artistName}}</view>
						<view class="price">
							<text class="l">价格:</text>
							<text class="r">￥{{$util.thousands(item.price)}}</text>
						</view>
					</view>
				</u-grid-item>
			</u-grid>
		</view>
	</view>
</template>

<script>
	import { mapState, mapGetters, mapActions, mapMutations } from 'vuex'
	export default {
		components: {
		},
		data() {
			return {
				tabs: [],
				current: 0,
				data: {}
			}
		},
		mounted() {
			this.getHomeCollection().then(res => {
				this.tabs = res.data
				this.data = this.tabs[0]
			})
		},
		methods: {
			...mapActions("home", ["getHomeCollection"]),
			onClickTab(item){
				this.current = item.index
				this.data = this.tabs[this.current]
			}
		}
	}
</script>

<style lang="scss" scoped>
	.category{
		margin-top: 30rpx;
		background-color: #484b5e;
		border-radius: 10rpx;
		padding-bottom: 10rpx;
		.tabs{
			.desc{
				padding: 20rpx 20rpx;
				font-size: 26rpx;
			}
		}
		.box{
			padding: 10rpx 0rpx;
			.grid-item{
			}
			.col{
				background-color: #0a0a22;
				border-radius: 10rpx;
				width: 96%;
				margin-bottom: 20rpx;
				.cover{
					position: relative;
				}
				.name{
					color: #ffffff;
					font-size: 26rpx;
					padding: 10rpx 10rpx;
				}
				.artist{
					color: #999999;
					font-size: 22rpx;
					padding: 0rpx 10rpx;
				}
				.price{
					display: flex;
					justify-content: space-between;
					font-size: 22rpx;
					padding: 20rpx 10rpx 30rpx 10rpx;
					.r{
						color: #fac22b;
					}
				}
			}
		}
	}
</style>
